/*    */ package cc.s2m.web.s2mBlog.controller.admin;
/*    */ 
/*    */ import cc.s2m.util.BeanConverter;
/*    */ import cc.s2m.util.Page;
/*    */ import cc.s2m.web.s2mBlog.controller.base.BaseController;
/*    */ import cc.s2m.web.s2mBlog.pojo.Comment;
/*    */ import cc.s2m.web.s2mBlog.service.IArticles;
/*    */ import cc.s2m.web.s2mBlog.service.IComment;
/*    */ import cc.s2m.web.s2mBlog.vo.Expressions;
/*    */ import cc.s2m.web.s2mBlog.vo.VO;
/*    */ import com.google.common.base.Strings;
/*    */ import java.util.HashMap;
/*    */ import java.util.Map;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.ui.Model;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ import org.springframework.web.bind.annotation.ResponseBody;
/*    */ 
/*    */ @Controller("admin_CommentController")
/*    */ @RequestMapping({"/admin/comment"})
/*    */ public class CommentController extends BaseController
/*    */ {
/*    */ 
/*    */   @Autowired
/*    */   private IComment commentService;
/*    */ 
/*    */   @Autowired
/*    */   private IArticles articlesService;
/*    */ 
/*    */   @RequestMapping({"/list"})
/*    */   public String list(Model model, Comment bean, Integer page)
/*    */   {
/* 34 */     if (page == null) page = Integer.valueOf(1);
/* 35 */     Map map = new HashMap();
/* 36 */     if (bean != null) {
/* 37 */       map.putAll(BeanConverter.toMap(bean, false));
/* 38 */       model.addAttribute("bean", bean);
/*    */     }
/* 40 */     VO vo = new VO();
/* 41 */     if (!Strings.isNullOrEmpty(bean.getMsg())) {
/* 42 */       map.remove("msg");
/* 43 */       vo.and(Expressions.like("msg", "%" + bean.getMsg() + "%"));
/*    */     }
/* 45 */     if (!Strings.isNullOrEmpty(bean.getLinkMsg())) {
/* 46 */       map.remove("linkMsg");
/* 47 */       vo.and(Expressions.like("msg", "%" + bean.getLinkMsg() + "%"));
/*    */     }
/* 49 */     map.put("vo", vo);
/* 50 */     Page pageBean = this.commentService.getPage(page.intValue(), 50, null, map);
/* 51 */     model.addAttribute("pageBean", pageBean);
/* 52 */     return "admin/comment";
/*    */   }
/*    */ 
/*    */   @RequestMapping(value={"/add"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public String add(Model model, Integer id) {
/* 57 */     if (id != null) {
/* 58 */       Comment bean = (Comment)this.commentService.selectByPrimaryKey(id);
/* 59 */       model.addAttribute("bean", bean);
/*    */     }
/* 61 */     return "admin/comment_add";
/*    */   }
/*    */ 
/*    */   @RequestMapping(value={"/view"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public String view(Model model, Integer id) {
/* 66 */     if (id != null) {
/* 67 */       Comment bean = (Comment)this.commentService.selectByPrimaryKey(id);
/* 68 */       model.addAttribute("bean", bean);
/*    */     }
/* 70 */     return "admin/comment_view";
/*    */   }
/*    */   @RequestMapping(value={"/save"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   @ResponseBody
/*    */   public String save(Model model, Comment bean) {
/* 76 */     if (bean == null) {
/* 77 */       return "empty";
/*    */     }
/* 79 */     if (bean.getId() == null)
/*    */     {
/* 81 */       this.commentService.insertSelective(bean);
/*    */     }
/*    */     else {
/* 84 */       this.commentService.updateByPrimaryKeySelective(bean);
/*    */     }
/* 86 */     return "success";
/*    */   }
/*    */   @RequestMapping(value={"/del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   @ResponseBody
/*    */   public String del(Integer id) {
/* 92 */     Comment bean = (Comment)this.commentService.selectByPrimaryKey(id);
/* 93 */     if (bean != null) {
/* 94 */       this.articlesService.removeCommentNumber(bean.getAid().intValue());
/* 95 */       this.commentService.deleteByPrimaryKey(id);
/*    */     }
/* 97 */     return "success";
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\s2mBlog.zip
 * Qualified Name:     s2mBlog-3.0.0.WEB-INF.classes.cc.s2m.web.s2mBlog.controller.admin.CommentController
 * JD-Core Version:    0.6.1
 */